#define  _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<math.h>
int main() {
    long n, t, p;
    long sum = 0;
    scanf("%ld", &n);
    for (long i = pow(10, n - 1);i < pow(10, n);i++) {
        sum = 0;
        t = i;
        for (int j = 1;j <= n;j++) {
            p = t % 10;
            sum += pow(p, n);
            t = t / 10;
        }
        if (sum == i)
            printf("%ld\n", sum);
    }
    return 0;
}